<?php
/**
 * 城市管理类
 * User: zal
 * Date: 2016/3/27
 * Time: 12:42
 */
namespace Api\Controller;
use Api\Controller\BaseController;

class CityController extends BaseController {

    public function index(){

    }

    /**
     * 获取省份
     */
    public function getProvince(){
        $provinceList=M('Province')->select();
        $data["provinceList"]=$provinceList;
        $data["code"]=200;
        $data["msg"]='ok';
        $this->ajaxReturn($data,'JSON');
    }

    /**
     * 获取省份下的城市
     */
    public function getCity(){
        //解决跨域
        echoHeader();
        $province_num=I('get.province_num','');
        $bankCards=array();
        if(empty($province_num)){
            $data["code"]=1001;
            $data["msg"]='缺少参数';
            $this->ajaxReturn($data,'JSON');
        }
        $map["province_num"]=$province_num;
        $provice=M('Province')->where($map)->find();
        if(empty($provice)){
            $data["code"]=1009;
            $data["msg"]='不存在的省份编号';
            $this->ajaxReturn($data,'JSON');
        }
        $cityList=M('City')->where($map)->select();
        $data["cityList"]=$cityList;
        $data["code"]=200;
        $data["msg"]='ok';
        $this->ajaxReturn($data,'JSON');
    }
}